using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.Design;
using System.ComponentModel.Design;
using System.Drawing;
using System.Web.UI.WebControls;

namespace BlogControl
{
    [SupportsPreviewControl(true)]

    class BlogDesigner : ControlDesigner
    {
        private DesignerAutoFormatCollection _autoformats = null;
        public override DesignerAutoFormatCollection AutoFormats
        {

            get
            {
                if (_autoformats == null)
                {
                    _autoformats = new DesignerAutoFormatCollection();
                    _autoformats.Add(new BlogAutoFormat("Gray"));
                    _autoformats.Add(new BlogAutoFormat("Black-Orange"));
                    _autoformats.Add(new BlogAutoFormat("Blue-Green"));
                }
                return _autoformats;
            }
        }
        public override DesignerActionListCollection ActionLists
        {
            get
            {
                DesignerActionListCollection d = new DesignerActionListCollection();
                d.Add(new DesignerActionsList(this));
                return d;
            }
        }
        class BlogAutoFormat : DesignerAutoFormat
        {
            public BlogAutoFormat(string name)
                : base(name)
            {
            }
            
            public override void Apply(System.Web.UI.Control control)
            {
                Blog ctrl = control as Blog;
                if (ctrl != null)
                {

                    switch (this.Name)
                    {
                        case "Gray":
                            ctrl.ControlStyle.Reset();
                            FontInfo fi = ctrl.SubjectFont;
                            fi.Name = "Verdana";
                            fi.Underline = false;
                            fi.Size = FontUnit.Parse("15px");
                           // ctrl.SubjectFont = fi;
                            ctrl.SubjectForeColor = ColorTranslator.FromHtml("#5C9EDC");
                            ctrl.BodyBorderColor = ColorTranslator.FromHtml("#456890");
                            ctrl.BackColor = Color.White;
                            ctrl.BodyForeColor = Color.Silver;
                            ctrl.PermalinkColor = ColorTranslator.FromHtml("#5c80b1");
                            ctrl.CommentsCountColor = ColorTranslator.FromHtml("#5c80b1");
                            fi = ctrl.CommentsFont;
                            fi.Name = "Verdana";
                            fi.Size = FontUnit.Parse("11px");
                            fi.Bold = true;
                            ctrl.DateFormat = "yyyy-MM-dd";
                            ctrl.CommentsAuthorColor = Color.Black;
                            ctrl.AddCommentLinkColor = Color.Black;
                            ctrl.CommentsSubjectColor = Color.Black;
                            ctrl.CommentsPublishDateColor = Color.Black;
                            ctrl.CommentsBodyColor = Color.Black;
                            ctrl.AddCommentsBoxTextColor = Color.Black;
                            ctrl.AddPostTextColor=Color.Black;
                            break;
                        case "Black-Orange":
                            ctrl.ControlStyle.Reset();
                            ctrl.SubjectFont.Size = FontUnit.Parse("1.1em");
                            ctrl.SubjectFont.Names = new string[] { "Verdana", "Arial", "Helvetica" };
                            ctrl.SubjectForeColor = ColorTranslator.FromHtml("#FF9900");//orange
                            ctrl.BackColor = Color.Black;
                            ctrl.BodyForeColor = Color.White;
                            ctrl.PermalinkColor = ColorTranslator.FromHtml("#FF9900");//orange
                            ctrl.CommentsCountColor = ColorTranslator.FromHtml("#FF9900");//orange
                            ctrl.CommentsSubjectColor = Color.White;
                            ctrl.CommentsPublishDateColor = Color.White;
                            ctrl.CommentsBodyColor = Color.White;
                            ctrl.CommentsAuthorColor = ColorTranslator.FromHtml("#FF9900");//orange
                            ctrl.AddCommentsBoxTextColor = Color.White;
                            ctrl.AddCommentLinkColor = Color.White;
                            ctrl.AddPostTextColor = Color.White;
                            break;
                        case "Blue-Green":
                            ctrl.ControlStyle.Reset();
                            ctrl.SubjectFont.Size = FontUnit.Parse("200%");
                            ctrl.SubjectFont.Bold = true;
                            ctrl.SubjectFont.Names = new string[] {"Century schoolbook","gerogia", "Lucida grande","Verdana","Helvetica", "Arial" };
                            ctrl.SubjectForeColor = Color.White;
                            ctrl.BorderColor = ColorTranslator.FromHtml("#456890");
                            ctrl.BackColor = ColorTranslator.FromHtml("#09386E");//blue
                            ctrl.BodyForeColor = ColorTranslator.FromHtml("#b5cae1");//light blue
                            ctrl.PermalinkColor = ColorTranslator.FromHtml("#b5cae1");//light blue
                            ctrl.CommentsCountColor = Color.White;
                            ctrl.CommentsFont.Size = FontUnit.Parse("60%");
                            ctrl.CommentsFont.Names = new string[] { "Georgia", "Century schoolbook", "Lucida grande", "Verdana", "Helvetica", "Arial" };
                            ctrl.CommentsFont.Bold = true;
                            ctrl.DateFormat = "D";
                            ctrl.CommentsAuthorColor = ColorTranslator.FromHtml("#9FE722");//green
                            ctrl.AddCommentLinkColor = ColorTranslator.FromHtml("#9FE722");//green
                            ctrl.CommentsSubjectColor = ColorTranslator.FromHtml("#b5cae1");//light blue
                            ctrl.CommentsPublishDateColor = ColorTranslator.FromHtml("#b5cae1");//light blue
                            ctrl.CommentsBodyColor = ColorTranslator.FromHtml("#b5cae1");//light blue
                            ctrl.AddCommentsBoxTextColor = Color.White;
                            ctrl.AddPostTextColor = Color.White;
                            break;
                    }
                }
            }
        }
    }
}
